#ifndef PROTO_PARSER_H
#	define PROTO_PARSER_H

#include "../../include/config.h"

#include "request.h"
#include "reply.h"

namespace HappyDB
{
namespace Protocal
{



typedef struct struct_token
{
	char * value;
	int length;
}
token_t;

class CProtoParser 
{
public:
	CProtoParser();
	~CProtoParser();

public:
	int do_parser(token_t * tokens, char * pstr);
	int try_parser(REQUEST * pReq, char * pstr); 
};

// for string to lower 
template<typename T>
     T ToLowerFunc(T Src, std::locale *Loc)
{
     return std::tolower(Src, *Loc);
}

template<class T>
     void MakeLower(T &Src, const char *Lang   = "english")
{
     static T::value_type (*pFunc)(T::value_type, std::locale*) = ToLowerFunc<T::value_type>;
     std::locale locE(Lang);
     std::transform(Src.begin(),Src.end(),Src.begin(),std::bind2nd(std::ptr_fun(pFunc), &locE));
}



}
}

#endif